<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta content="telephone=no,email=no" name="format-detection">
    <meta name="renderer" content="webkit">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate, post-check=0, pre-check=0">
    <meta http-equiv="Expires" content="0">
    <link rel="stylesheet" href="<%- Virtual_Path.Static %>main/template/mobile/css/index.css">
    <script src="<%- Virtual_Path.Static %>common/js/flexible/flexible.js"></script>
    <script type="text/javascript">
        window.jQuery || document.write("<script src='<%- Virtual_Path.Static %>jquery/jquery-2.1.4.min.js'>" + "<" + "/script>");
    </script>
    <!-- lodash -->
    <script src="<%- Virtual_Path.Static %>jquery.plugin/lodash/lodash.min.js"></script>
    <!-- moment -->
    <script src="<%- Virtual_Path.Static %>jquery.plugin/moment/moment.min.js"></script>
    <!-- Socket.IO -->
    <script src="<%- Virtual_Path.Socket %>socket.io/socket.io.js"></script>
    <!-- PageScript -->
    <script><%- PageScript %></script>
    <!-- perfect-scrollbar???? -->
    <link rel="stylesheet" href="<%- Virtual_Path.Static %>jquery.plugin/perfect-scrollbar/css/perfect-scrollbar.min.css"/>
    <script src="<%- Virtual_Path.Static %>jquery.plugin/perfect-scrollbar/js/perfect-scrollbar.jquery.min.js"></script>

    <title>直播间</title>
</head>
<body>
<div class="XY-pager clearfix">
    <div class="XY-Main" id="J_AnchorMain">
        <div class="XY-Anchor">
            <!-- 视频播放区 -->
            <section class="xy-player" id="J_VideoTag">
                <div class="anchor-poster" id="J_AnchorPosterBg" style="pointer-events:none;"></div>
                <div class="loading-container" style="pointer-events:none;">
                    <a href="javascript:;" class="loading"></a>
                </div>
                <div id="J_Player" style="position:absolute;width:100%;height:100%;left:0;top:0;overflow:hidden;text-align:center;">
                    <!-- Video Content -->
                </div>
                <div class="icon-player" id="J_StartPlayBtn"></div>
            </section>
            <!-- 艺人个人信息 -->
            <section class="anchor-info">
                <div class="cover">
                    <img id="J_RoomAnchorHeadImg">
                </div>
                <div class="nickname">
                    <span id="J_AnchorNickName">-</span>
                </div>
                <div class="fans-total">
                    <span id="J_AttentionNum">-</span>
                </div>
            </section>
            <p class="attentionbtn" data-download="true">关注</p>
        </div>
        <!--聊天区-->
        <div class="activity-container">
            <div class="activity-content">
                <div class="chat-content">
                    <div class="chat-transition" style="transition-timing-function: cubic-bezier(0.4, 0, 1, 1);transition-duration: 250ms;transform: translate(0, 0) translateZ(0px);">
                        <ul class="chat-list clearfix" id="J_Chatlistinfo">
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <!--聊天输入框-->
        <div class="talk-container">
            <div class="toolbar-talk-content">
                <a href="http://utils.quanminxiu.tv/service/download/app/" class="tools-talk-icon"></a>
                <a class="tools-talk-input" placeholder="快跟艺人互动吧！" href="http://utils.quanminxiu.tv/service/download/app"></a>
            </div>
            <div class="toolbar-gift-content">
                <a href="http://utils.quanminxiu.tv/service/download/app" class="tools-gift-ico"></a>
            </div>
        </div>
        <div class="xy-tip-info" style="display: none"><p>直播已结束</p></div>
        <!--提示下载-->
        <section class="download-app">
            <div class="xy-logo" data-download="true"></div>
            <div class="dl-button-area">
                <a href="http://utils.quanminxiu.tv/service/download/app" target="_blank" class="dl-button-app"></a>
            </div>
        </section>

    </div>
    <div class="XY-OtherInfo">
        <div class="xy-videobox">
            <h2 class="title">大家都在看</h2>
            <div class="videolist clearfix">
                <ul id="J_AnchorList" class="clearfix">

                </ul>
            </div>
        </div>
    </div>
</div>




<!-- COMMON JS FILE -->
<script src="/js/common.js"></script>
<script src="/js/common.main.js"></script>
<script src="/js/common.main.room.js"></script>
<script type="text/javascript">
    String.prototype.replaceAll = function (s1, s2) {
        return this.split(s1).join(s2);
    }
    $(function () {
        var Device = function(){
            var agent = navigator.userAgent.toLowerCase();
            var parseVersion = function(label){
                var exp = new RegExp(label+'/([^\\s\\_\\-]+)');
                label = (agent.match(exp)||[])[1];
                return label ? label.replace(/(?!^\d+\.)(\b\d+)./g, '$1') : false
            };
            var result = {};
            if(/windows/.test(agent)) result.os = "windows";
            if(/linux/.test(agent)) result.os = "linux";
            if(/iphone|ipod|ipad|ios/.test(agent)) result.os = "ios";
            result.android = /android/.test(agent); //是否安卓
            result.mobile = /mobile/.test(agent); //是否移动设备
            result.weixin = parseVersion('micromessenger');//获取微信版本，不在微信WebWiew则返回fa
            result.myapp = parseVersion('myapp');//获取你的App版本，不在App WebWiew则返回falase。记得把myapp改成你的app特殊标识
            result.agent = agent;
            return result;
        };
        var Log = {
            Out: function (label, str) {
                var url = String(window.document.location.href);
                if (url.indexOf('http://www.quanminxiu.tv/') != -1 && url.indexOf('?debug') == -1) {
                    return;
                }
                if (str) {
                    console.log(label, str);
                    return;
                }
                console.log(label);
            }
        };
        var _ThisPage = {
            Page: {
                //页面初始化就执行
                Init: function () {
                    //是否移动设备
                    if(!Device().mobile){
                        window.document.location = "/room/"+_PageData.RoomID;
                        return;
                    }else{
                        //移动设备尝试打开APP
                        _ThisPage.App.OpenApp();
                    }
                    _ThisPage.AnchorList.Init();
                },
                //进房成功
                JoinComplete: function (data) {
                    //艺人相关初始化
                    _ThisPage.Page.Anchor.Init(data);
                    //房间初始化
                    _ThisPage.Page.Room.Init(data);
                    //聊天功能初始化
                    _ThisPage.Page.Chat.Init(data);
                    //视频区初始化
                    _ThisPage.Page.Video.Init(data);
                    //下载App
                    _ThisPage.Page.AppDown.Init();
                },
                /**
                 * 公共方法
                 */
                CommonUitls: {
                    //获取用户头像
                    GetUserHand: function (User_ID, Size) {
                        Size = (Size) ? Size : "54.54";
                        return $.Common.ImageBind.UserAvatar.fnURL(User_ID, Size);
                    },
                    //获取艺人头像
                    GetAvatarHand: function (User_ID, Size) {
                        Size = (Size) ? Size : "80.80";
                        return $.Common.ImageBind.UserCover.fnURL(User_ID, Size);
                    },
                    //系统提示
                    Tip: function (data, settings) {
                        $.CommonMain.Modal_Tip(data, settings);
                    }
                },
                /**
                 * 房间相关
                 */
                Room: {
                    //初始化
                    Init: function (data) {
                        $('#J_AnchorPosterBg').css({'background-image':'url('+_ThisPage.Page.CommonUitls.GetAvatarHand(data.RoomInfo.RoomID,'146.146')+')'});
                    },
                    //更新房间相关信息
                    UpdateInfo: function (data) {
                        if (!data) return;
                        var LiveTime = (data.Live_CreateDate == undefined) ? '未开播' : moment(data.Live_CreateDate).format('HH:mm')+' 开播';
                    }
                },
                /**
                 * 艺人相关
                 */
                Anchor: {
                    Init: function (data) {
                        $('#J_RoomAnchorHeadImg').attr('src', _ThisPage.Page.CommonUitls.GetUserHand(data.RoomAnchorInfo.RoomID, '80.80'));
                        $('#J_RoomAnchorHeadImg').attr('alt', data.RoomAnchorInfo.NickName);
                        $('#J_AnchorNickName').text(data.RoomAnchorInfo.NickName);
                    },
                    //更新艺人相关信息
                    UpdateInfo: function (data) {
                        $("#J_Anchor_NickName").text(data.NickName).attr("title", data.NickName);//艺人昵称
                        $("#J_AttentionNum").text($.CommonMainRoom.RoomAnchorInfo.Fans);
                    }
                },
                /**
                 * 视频相关
                 */
                Video: {
                    //初始化
                    Init: function (data) {
                        var _This = _ThisPage.Page.Video;
                        $('#J_Player').html(_ThisPage.Page.Video.GetVideoHtml());
                        if($.CommonMainRoom.RoomInfo.Live){
                            _This.Playing(true);
                            $('#J_Video').hide();
                        }else{
                            _This.Playing(false);
                        }

                        $('#J_StartPlayBtn').off('click');
                        $('#J_StartPlayBtn').on('click', function(){
                            if(!$.CommonMainRoom.RoomInfo.Live){
                               alert("当前艺人休息中，稍候再来！");
                               return;
                            }
                            $('#J_Video')[0].play();
                            $('#J_Video').show();
                            $('#J_StartPlayBtn').hide();
                        });
                    },
                    //是否播放视频中
                    Playing: function (isPlaying) {
                        if (isPlaying)
                        {
                            var isMobile = $.CommonMainRoom.RoomInfo.Live_IsMobile;
                            $('#J_Player').html(_ThisPage.Page.Video.GetVideoHtml());
                            $('#J_StartPlayBtn').show();
                            $('#J_Video').show();
                            $('.activity-container').show();
                            $('.talk-container').show();
                            $('.xy-tip-info').hide();
                            $("#J_AnchorMain").removeClass('LiveEnd');
                            var W = window.screen.width;
                            var H = window.screen.height;
                            var VW = $('#J_Video').width();
                            var L = ((VW-W)/2/75)+"rem";
                            $('#J_Video').css({marginLeft:-L});
                            if(isMobile) $('#J_Video').width('100%');
                            //alert([1, W,H,L,VW].toString())
                        }
                        else
                        {
                            $('#J_StartPlayBtn').hide();
                            $('#J_Video').hide();
                            $('.activity-container').hide();
                            $('.talk-container').hide();
                            $('.xy-tip-info').show();
                            $("#J_AnchorMain").addClass('LiveEnd');
                        }
                    },
                    GetVideoHtml:function(){
                        var isMobile = $.CommonMainRoom.RoomInfo.Live_IsMobile;
                        var wb = (isMobile) ? "100%" : "auto";
                        var hb = (isMobile) ? "auto" : "100%";
                        var lb = (isMobile) ? "0%" : "-90%";
                        var m3u8 = _ThisPage.Page.Video.GetM3u8($.CommonMainRoom.RoomInfo.Live_URL);//m3u8 = "http://bf9.quanminxiu.tv/xiyoulive/ROOM_test.m3u8";
                        var W = window.screen.width;
                        var H = window.screen.height;
                        var html = '<video id="J_Video" ' +
                                'x-webkit-airplay="true" ' +
                                'webkit-playsinline="true" ' +
                                'playsinline="true" ' +
                                'preload="auto" ' +
                                'x5-video-player-fullscreen="false" ' +
                                'x5-video-player-type="h5" ' +
                                'style="position:absolute;left:'+lb+';width:'+wb+';height:'+hb+';" ' +
                                'src="'+m3u8+'">' +
                                '<span>您的手机版本，网页版暂未能支持！</span>' +
                                '</video>';
                        return html;
                    },
                    GetM3u8:function(Live_URL){
                        var url = Live_URL.replace('rtmp://', 'http://');
                        url = url+'.m3u8';
                        return url;
                    }
                },
                /**
                 * 聊天
                 */
                Chat: {
                    Data: {
                        Word: [],//脏话 过滤词
                        Intreval: 0,//发言时间间隔
                        Maxlength: 0,//发送文字最长限制
                        isCanSend: true,//是否 可以发送文字
                        isMouseAreaFaceEmo: false,//鼠标是否在 表情区域
                        MsgMaxCount: 500,//最大条数
                        TestInterval: 0,//测试Interval
                        TestMaxCount: 0,//测试消息条数
                        TestCurrCount: 0,//测试数据当前条数

                        MsgArr: [],//当前消息 xxx
                        MsgObj: null,//当前消息

                        IsPrivate: false, //是否 私聊区
                        IsHorn: false, //是否 喇叭状态
                        IsFly: false, //是否 飞屏状态
                        LastPlaceholder: '', //上次的提示
                        IsLockScroll: false, //是否 锁定滚动区

                        GuestEnterRoomTime:0,//当前发言时间，计时10秒显示一次，游客进入的功能

                        ChatUser: { //公聊 私聊 切换数据
                            Receiver: null,
                            Private: false,
                            PrivateTa: false
                        },
                        Config: [
                            //等级    发言间隔    聊天字数    是否允许私聊
                            {level: 0, interval: 5, char: 10, private: 0},
                            {level: 1, interval: 3, char: 30, private: 0},
                            {level: 2, interval: 3, char: 30, private: 0},
                            {level: 3, interval: 3, char: 30, private: 1},
                            {level: 4, interval: 3, char: 30, private: 1},
                            {level: 5, interval: 3, char: 30, private: 1},
                            {level: 6, interval: 3, char: 30, private: 1},
                            {level: 7, interval: 3, char: 30, private: 1},
                            {level: 8, interval: 3, char: 30, private: 1},
                            {level: 9, interval: 3, char: 30, private: 1},
                            {level: 10, interval: 2, char: 30, private: 1},
                            {level: 11, interval: 2, char: 30, private: 1},
                            {level: 12, interval: 2, char: 30, private: 1},
                            {level: 13, interval: 2, char: 30, private: 1},
                            {level: 14, interval: 2, char: 30, private: 1},
                            {level: 15, interval: 2, char: 30, private: 1},
                            {level: 16, interval: 2, char: 30, private: 1},
                            {level: 17, interval: 2, char: 30, private: 1},
                            {level: 18, interval: 2, char: 30, private: 1},
                            {level: 19, interval: 1, char: 30, private: 1},
                            {level: 20, interval: 1, char: 30, private: 1},
                            {level: 21, interval: 1, char: 30, private: 1},
                            {level: 22, interval: 1, char: 30, private: 1},
                            {level: 23, interval: 1, char: 30, private: 1},
                            {level: 24, interval: 1, char: 30, private: 1},
                            {level: 25, interval: 1, char: 30, private: 1},
                            {level: 26, interval: 1, char: 30, private: 1},
                            {level: 27, interval: 1, char: 30, private: 1},
                            {level: 28, interval: 1, char: 30, private: 1},
                            {level: 29, interval: 1, char: 30, private: 1},
                            {level: 30, interval: 1, char: 30, private: 1},
                            {level: 31, interval: 1, char: 30, private: 1},
                            {level: 32, interval: 1, char: 30, private: 1},
                            {level: 33, interval: 1, char: 30, private: 1},
                            {level: 34, interval: 1, char: 30, private: 1},
                            {level: 35, interval: 1, char: 30, private: 1},
                            {level: 36, interval: 1, char: 30, private: 1}
                        ]
                    },
                    //测试自动发布消息
                    TestAutoSendMsg: function () {
                        if (_ThisPage.Page.Chat.Data.TestCurrCount >= _ThisPage.Page.Chat.Data.TestMaxCount) {
                            clearInterval(_ThisPage.Page.Chat.Data.TestInterval);
                            $("#J_InputTextWord").val("game over");
                            _ThisPage.Page.Chat.Data.TestCurrCount = 0;
                            _ThisPage.Page.Chat.Data.TestMaxCount = 0;
                            return;
                        }
                        _ThisPage.Page.Chat.Data.TestCurrCount++;
                        $("#J_InputTextWord").val("Test Text " + _ThisPage.Page.Chat.Data.TestCurrCount);
                        var txt = $("#J_InputTextWord").val();
                        var msgObj = {};
                        msgObj.Private = false;
                        msgObj.PrivateTa = false;
                        msgObj.text = txt;
                        msgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat($.CommonMainRoom.RoomUserInfo);
                        msgObj.User2 = null;
                        _ThisPage.Page.Chat.Data.MsgObj = msgObj;
                        // _ThisPage.Page.Chat.ChatShowMsg(msgObj);
                        $.CommonMainRoom.SocketEmit.Message(msgObj.text);
                    },
                    //公共方法
                    CommonUtils: {
                        GetUserName: function (UserInfo) {
                            // Log.Out("公共方法 GetUserName", [UserData.RoomID, $.CommonMainRoom.RoomAnchorInfo.RoomID]);
                            var isRoomAnchor = (UserInfo.User_ID == $.CommonMainRoom.RoomInfo.RoomID);
                            var userType = (isRoomAnchor) ? 'anchor' : 'user' ;
                            var userLevel = (isRoomAnchor) ? $.CommonMainRoom.RoomAnchorInfo.Level : UserInfo.Level ;
                            var _ClassType = (isRoomAnchor) ? 'level-anchor' : 'level-user' ;

                            var html = '<img src="http://cdn.static.quanminxiu.tv/main/image/common/level/'+userType+'/'+userLevel+'.png" alt="'+userLevel+'" class="'+_ClassType+'">' +
                                    '<span class="nickname">'+UserInfo.NickName+':</span>';
                            return html;
                        },
                        //系统提示格式
                        GetSysHtml:function(SysTip, Text){
                            SysTip = (SysTip) ? SysTip : '系统消息' ;
                            var html = '<li class="welcome">' +
                                    '<p class="msg-content">' +
                                    '<span class="nickname">'+SysTip+'</span>' +
                                    Text +
                                    '</p>' +
                                    '</li>';
                            $("#J_Chatlistinfo").append(html);
                            _ThisPage.Page.Chat.ChatScrollToBottom();
                        },
                        //欢迎格式
                        GetWelComHtml:function(UserInfo){
                            var html = '<li class="welcome">' +
                            '<p class="msg-content"><span class="nickname">'+UserInfo.NickName+'</span>进入直播间</p>' +
                            '</li>';
                            $("#J_Chatlistinfo").append(html);
                            _ThisPage.Page.Chat.ChatScrollToBottom();
                        },
                        //聊天格式
                        GetTalkHtml:function(UserData, Text){
                            var isRoomAnchor = (UserData.User_ID == $.CommonMainRoom.RoomInfo.RoomID);
                            var userType = (isRoomAnchor) ? 'anchor' : 'user' ;
                            var userLevel = (isRoomAnchor) ? $.CommonMainRoom.RoomAnchorInfo.Level : UserData.Level ;
                            var html = '<li>' +
                                    '<p class="msg-content">' +
                                    _ThisPage.Page.Chat.CommonUtils.GetUserName(UserData) +
                                    _ThisPage.Page.Chat.FaceEmo.FaceEscape(UserData, Text) +
                                    '</p>' +
                                    '</li>';
                            $("#J_Chatlistinfo").append(html);
                            _ThisPage.Page.Chat.ChatScrollToBottom();
                        },
                        //送礼格式
                        GetGiftHtml:function(data){
                            var isRoomAnchor = (data.UserInfo.User_ID == $.CommonMainRoom.RoomInfo.RoomID);
                            var userType = (isRoomAnchor) ? 'anchor' : 'user' ;
                            var userLevel = (isRoomAnchor) ? $.CommonMainRoom.RoomAnchorInfo.Level : data.UserInfo.Level ;
                            var msg = '<li><p class="msg-content">' +
                                    '<img src="http://cdn.static.quanminxiu.tv/main/image/common/level/'+userType+'/'+userLevel+'.png" alt="#" class="level-user">' +
                                    '<span class="nickname">'+data.UserInfo.NickName+':</span> 赠送 '+data.GiftName+' <img src="' + _VirtualPath.Static + 'main/image/room/gift/' + data.Gift_ID + '.png" alt="" class="main-chat-sys-gift"> x '+data.Num+' 个</p></li>';
                            $("#J_Chatlistinfo").append(msg);
                            _ThisPage.Page.Chat.ChatScrollToBottom();
                        }

                    },
                    //初始化
                    Init: function (data) {
                        $(".chat-content").perfectScrollbar();

                        _ThisPage.Page.Chat.CommonUtils.GetSysHtml('系统消息：', "<a href='" + _VirtualPath.Main + "activity/2016/firstpay' target='_blank' class='alink'>首次充值赠送超值大礼包！</a>");
                        _ThisPage.Page.Chat.CommonUtils.GetSysHtml('安全提示：', "聊天中若涉及财产的操作，冒充官方人员，请联系官方客服核实对方身份，谨防受骗！");
                        _ThisPage.Page.Chat.CommonUtils.GetWelComHtml(data.RoomUserInfo);
                    },
                    //获取 聊天 用户数据格式
                    GetMsgUserFormat: function (UserData) {
                        var data = {};
                        data.isGuest = UserData.Guest;
                        data.IsAdmin = UserData.IsAdmin;
                        data.IsAnchor = UserData.IsAnchor;
                        data.IsFamily = UserData.IsFamily;
                        data.IsMobile = UserData.IsMobile;
                        data.User_ID = UserData.User_ID;
                        data.Level = UserData.Level;
                        data.AnchorLevel = (data.User_ID == $.CommonMainRoom.RoomAnchorInfo.RoomID) ? $.CommonMainRoom.RoomAnchorInfo.Level : -1;
                        data.NickName = UserData.NickName;
                        data.RoomAdmin = UserData.RoomAdmin;
                        data.RoomAnchor = UserData.RoomAnchor;
                        data.RoomGuardian = UserData.RoomGuardian;
                        data.RoomGuardianMode = UserData.RoomGuardian_Mode;
                        data.VIP = UserData.VIP;
                        data.EmblemList = (UserData.EmblemList != null) ? UserData.EmblemList : null;
                        return data;
                    },
                    //接收消息处理
                    ChatServerMsgReceive: function (data) {
                        data.Receiver = data.RoomUserInfo_Receiver;//兼容
                        var msgObj = {};
                        if (data.Private) {
                            msgObj.Private = (data.Private) ? data.Private : false;
                            msgObj.PrivateTa = (data.Sender) ? true : false;
                            msgObj.text = data.Message;
                            msgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat(data.RoomUserInfo);
                            msgObj.User2 = _ThisPage.Page.Chat.GetMsgUserFormat($.CommonMainRoom.RoomUserInfo);
                            $("#J_ChatNewMsgTip").addClass('NewMsgRec').show();
                        } else {
                            msgObj.Private = (data.Private) ? data.Private : false;
                            msgObj.PrivateTa = (data.Receiver) ? true : false;
                            msgObj.text = data.Message;
                            msgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat(data.RoomUserInfo);
                            msgObj.User2 = (data.Receiver) ? _ThisPage.Page.Chat.GetMsgUserFormat(data.Receiver) : null;
                        }
                        _ThisPage.Page.Chat.ChatShowMsg(msgObj);
                    },
                    //显示聊天消息
                    ChatShowMsg: function (msgObj) {
                        Log.Out("msgObj", msgObj);
                        var _This = this;
                        //回收html节省
                        if ($("#J_Chatlistinfo").children().length > _ThisPage.Page.Chat.Data.MsgMaxCount) {
                            $("#J_Chatlistinfo").children()[0].remove();
                        }
                        //脏话过滤
                        msgObj.text = _ThisPage.Page.Chat.MsgFilter(msgObj.text);
                        _ThisPage.Page.Chat.CommonUtils.GetTalkHtml(msgObj.User1, msgObj.text);
                    },
                    //进房提示语
                    RoomEnterNewUserNotify: function (data) {
                        _ThisPage.Page.Chat.CommonUtils.GetWelComHtml(data.RoomUserInfo);
                    },

                    //始终保持在底部
                    ChatScrollToBottom: function () {
                        if (_ThisPage.Page.Chat.Data.IsLockScroll) return;
                        $(".chat-content").scrollTop($('#J_Chatlistinfo').height());
                    },
                    //文字 消息 过滤
                    MsgFilter: function (txt) {
                        if (_ThisPage.Page.Chat.Data.Word.length > 0) {
                            _ThisPage.Page.Chat.Data.Word.forEach(function (value) {
                                txt = _.replace(txt, value, _.repeat('*', value.length));
                                txt = txt.replaceAll(value, _.repeat('*', value.length));
                                // var starLen = _.repeat('*', value.length);
                                // var keyStr = value.split("").join('.{0,3}');
                                // var regexp = new RegExp(keyStr, "g");
                                // txt = txt.replace(regexp, starLen);
                            });
                        }

                        txt = filterUighurTibetan(txt);
                        txt = filterQQ(txt);

                        //过滤 维语藏语
                        function filterUighurTibetan(str) {
                            var s = "";
                            for (var i = 0; i < str.length; i++) {
                                var str1 = str.substr(i, 1);
                                var ascii = str1.charAt(i).charCodeAt();
                                var isUT = IsUighurTibetan(str1);
                                if (isUT) {
                                    s += "*";
                                } else {
                                    s += str1;
                                }
                            }
                            return s;
                        }
                        //是否 维语藏语
                        function IsUighurTibetan(char) {
                            var start = 1000;
                            var end = 5000;
                            var n = char.charAt().charCodeAt();
                            // Log.Out("ASCII", [char, n]);
                            return (n >= start && n <= end) ? true : false;
                        }

                        //QQ号码
                        function filterQQ(str){
                            var QQ_patt = new RegExp('([0-9]|\s| ){6,12}', "g");
                            return str.replace(QQ_patt, "*");
                        }

                        return txt;
                    },
                    //聊天区 表情符号
                    FaceEmo: {
                        //表情替换规则
                        FaceEscape: function (UserInfo, text) {
                            function replaceEmo(text) {
                                for (var i = 1; i <= 56; i++) {
                                    var key = '[f' + i + ']';
                                    text = text.replaceAll(key, '<img src="' + _VirtualPath.Static + 'main/image/emo/emoji/emoji_' + i + '.png"  class="chat-emoticon" />');
                                }
                                return text;
                            }

                            function replaceEmoVIP(text) {
                                for (var i = 1; i <= 24; i++) {
                                    var key = '[v' + i + ']';
                                    text = text.replaceAll(key, '<img src="' + _VirtualPath.Static + 'main/image/emo/common/e' + i + '.png" class="chat-emoticon" />');
                                }
                                return text;
                            }

                            function replaceEmoGuard(text) {
                                for (var i = 1; i <= 10; i++) {
                                    var key = '[g' + i + ']';
                                    text = text.replaceAll(key, '<img src="' + _VirtualPath.Static + 'main/image/emo/guard/e' + i + '.png"  class="chat-emoticon"/>');
                                }
                                return text;
                            }

                            text = text.replace(/\&/g, '&amp;');
                            text = text.replace(/\</g, '&lt;');
                            text = text.replace(/\>/g, '&gt;');
                            text = text.replace(/\"/g, '&quot;');
                            text = text.replace(/\'/g, '&#039;');
                            // 循环
                            text = replaceEmo(text);
                            if (UserInfo.VIP) text = replaceEmoVIP(text);
                            if (UserInfo.RoomGuardian) text = replaceEmoGuard(text);
                            return text;
                        }
                    },
                },
                /**
                 * 礼物功能
                 */
                Gift: {
                    Data: {
                        GiftId: 58, // 当前选中的礼物ID 默认黄瓜
                        GiftListIndex: 0, //当前选中的礼物列表索引
                        GiftNum: 1, // 当前选中的礼物数量 默认1
                        TargetUserId: 0, //赠送目标ID
                        // sending:false, //是否 正在赠送中
                        isEffectOn: true, //是否 效果 开启
                        GiftSendBtnTimeout: 0, //赠送按钮动画
                        GiftSendBtnInterval: 0, //赠送按钮动画
                        IntervalNum: 0, //赠送按钮动画

                        GiftTag: ["Hot", "Package"], //当前礼物类型 标签
                        CurrTag: null, //当前 标签 类型

                        GiftDefaultShowIndex: 0, //礼物列表默认 显示礼物 索引
                        PackageDefaultShowIndex: 0 //包裹列表默认 显示 索引
                    },
                    //初始化
                    Init: function (data) {
                    },
                    //礼物赠送 返回 结果 temp
                    RoomGiftGiveResult: function (data) {
                        var _This = _ThisPage.Page.Gift;
                        //为数据兼容做的
                        var giftData = {
                            CreateDate: data.CreateDate,
                            Count: data.GiftCount,
                            GiftStreamer: data.GiftStreamer,
                            Gift_ID: data.GiftInfo.id,
                            GiftName: data.GiftInfo.Name,
                            // Gift_Pond_Amt:data.GiftPond.Amt,
                            // Gift_Pond_TriggerAmt:data.GiftPond.BurstAmt,
                            Num: data.GiftNum,
                            UserInfo: data.RoomUserInfo,
                            UserInfo_Gift: (data.RoomUserInfo_Gift) ? data.RoomUserInfo_Gift : data.RoomAnchorInfo,
                            RoomAnchor: (data.RoomUserInfo_Gift) ? false : true,
                            RoomAnchorInfo: $.CommonMainRoom.RoomAnchorInfo
                        };
                        giftData.UserInfo_Gift.RoomAnchor = true;

                        //显示 礼物记录赠送 聊天区
                        _ThisPage.Page.Chat.CommonUtils.GetGiftHtml(giftData);

                        //幸运礼物暴奖文字
                        if (data.LuckyCoin > 0) {
                            var LuckyStr = "";
                            for (var i = 0; i < data.MultipleList.length; i++) {
                                var LuckyData = data.MultipleList[i];
                                LuckyStr += LuckyData.Multiple + '倍' + LuckyData.Count + '次，';
                            }
                            _ThisPage.Page.Chat.CommonUtils.GetSysHtml('系统提示：', '恭喜 ' + _ThisPage.Page.Chat.CommonUtils.GetUserName(data.RoomUserInfo) + ' 送出 ' + data.GiftNum + '个“' + data.GiftInfo.Name + '” 喜中 ' + LuckyStr + '共获得' + data.LuckyCoin + '金币！');
                        }
                    },
                },
                /**
                 * 星星
                 */
                PomeloUtil: {
                    Data: {
                        Num: 0,//星星数量
                        TempInterval: 0,//时间间隔5分钟 获取下星星
                        MaxTime: 60 * 5,//5分钟(秒)
                        CurrTime: 0,//当前时间
                        isFull: false,//当前是否累积满星星了
                        GiftName: '星星',//星星名称，改成【八芒星】
                        GiftId: 0 //暂定 星星ID 为 0
                    },
                    Init: function (data) {
                    },
                    //显示历史记录 谁赠送的星星
                    ShowPomeloHistoryList: function (data) {
                        var PomeloData = {
                            CreateDate: data.CreateDate,
                            Gift_ID: _ThisPage.Page.PomeloUtil.Data.GiftId,
                            GiftName: _ThisPage.Page.PomeloUtil.Data.GiftName,
                            Count: 0,
                            Num: 1,
                            RoomAnchor: true,
                            UserInfo: data.RoomUserInfo,
                            UserInfo_Gift: {
                                RoomAnchor: true,
                                NickName: data.RoomAnchorInfo.NickName,
                                Level: data.RoomAnchorInfo.Level
                                // NickName:$.CommonMainRoom.RoomAnchorInfo.NickName,
                                // Level:$.CommonMainRoom.RoomAnchorInfo.Level
                            },
                            RoomAnchorInfo: $.CommonMainRoom.RoomAnchorInfo
                        };
                        //显示 礼物记录赠送 聊天区
                        _ThisPage.Page.Chat.CommonUtils.GetGiftHtml(PomeloData);
                    }
                },
                /**
                 * 下载app
                 */
                AppDown:{
                    Init:function(){
                        $(document).on( "click", "[data-download=true]", function() {
                            window.location.href="http://utils.quanminxiu.tv/service/download/app";
                        });
                    }
                }
            },
            AnchorList:{
                CommonUtils:{
                    GetAnchorItem:function(Value, i){
                        //小图
                        var _LiveState='';
                        if(Value.Live == 1){
                            _LiveState='<i class="live-state"></i>'
                        }
                        var item1 = '<li>' +
                                '<a href="/room/'+Value.User_ID+'/m">' +
                                '<img src="'+$.Common.ImageBind.UserCover.fnURL(Value.User_ID, "146.146")+'" alt="'+Value.NickName+'" class="v-poster">' +
                                '<p class="main-intro">' +
                                '<span class="nickname">'+Value.NickName+'</span>' +
                                '<span class="fans-total">' + Value.Anchor_HotValue + '</span>' +
                                '</p>' +
                                '<div class="intro"><p class="topic">' + Value.RoomTitle + '</p></div>' +
                                 _LiveState+
                                '</a>' +
                                '</li>';
                        return item1;
                    }
                },
                Init:function(){
                    $('#J_AnchorList').empty();
                    Log.Out("加载头部 推荐艺人===>");
                    $.ajax({
                        url: '/ajaxs/rcommon.useranchorlisthot.get',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            Start:0,
                            Length:20
                        },
                        success: function (data) {
                            Log.Out("头部 推荐艺人 ", data);
                            if(data.flag !== 0) return;
                            _.forEach(data.data, function (Value, i) {
                                $('#J_AnchorList').append(_ThisPage.AnchorList.CommonUtils.GetAnchorItem(Value, i));
                            });
                        }
                    });
                }
            },
            App:{
                OpenApp:function(){
                    var agent = navigator.userAgent;
                    Log.Out("OpenApp = ", [agent, _PageData.RoomID]);
                    if(/mobile/i.test(agent)){//移动设备 调用设备上的应用
                        window.location.href = 'xiutv://liveroom/open?roomid='+_PageData.RoomID;
                    }
                }
            }
        };
        _ThisPage.Page.Init();
        $.CommonMainRoom.fnInit({
            SocketURL: _VirtualPath.Socket + 'room',
            RoomID: _PageData.RoomID,
            //
            onConnect: function () {
                Log.Out("onConnect");
            },
            onJoin: function (data) {
                Log.Out("onJoin", data);
                _ThisPage.Page.JoinComplete(data);
            },
            onJoinBroadcast: function (data) {
                Log.Out("onJoinBroadcast", data);
                if (data.RoomUserInfo.IsAdmin) return; //官方 进房信息 其他人不显示
                _ThisPage.Page.Chat.RoomEnterNewUserNotify(data);
            },
            onOutBroadcast: function (data) {
                Log.Out("onOutBroadcast", data);
            },
            onDisconnect: function () {
                Log.Out('onDisconnect');
                _ThisPage.Page.Video.Playing(false);
            },
            onUserList: function (data) {
                Log.Out("onUserList", data);
            },
            onUserLevelBroadcast: function (data) {
                Log.Out("onUserLevelBroadcast", data);
            },
            onAdminList: function (data) {
                Log.Out("onAdminList", data);
            },
            onAdminListBroadcast: function (data) {
                Log.Out("onUserLevelBroadcast", data);
            },
            onUserLevelBroadcast: function (data) {
                Log.Out("onUserLevelBroadcast", data);
            },
            onLive: function (data) {
                Log.Out("onLive", data);
                _ThisPage.Page.Video.Playing(true);
            },
            onLiveBroadcast: function (data) {
                Log.Out("onLiveBroadcast", data);
                if (data.Type == "LiveEnd-BlockSet")
                {
                    _ThisPage.Page.Video.Playing(false);
                    alert("此房间已被冻结！");
                    window.document.location = _VirtualPath.Main;
                    return;
                }
                else if (data.Type == "Live")
                {
                    if (data.RoomInfo.Live) {
                        _ThisPage.Page.Video.Playing(true);
                    } else {
                        _ThisPage.Page.Video.Playing(false);
                    }
                }
                else if (data.Type == "LiveEnd" || data.Type == "LiveEnd-Disconnect")
                {
                    _ThisPage.Page.Video.Playing(false);
                }
            },
            onRunwayBroadcast: function (data) {
                Log.Out("onRunwayBroadcast", data);
            },
            onGuardian: function (data) {
                Log.Out("onGuardian", data);
            },
            onGuardianBroadcast: function (data) {
                Log.Out("onGuardianBroadcast", data);
            },
            onGift: function (data) {
                Log.Out("onGift", data);
            },
            onGiftBroadcast: function (data) {
                Log.Out("onGiftBroadcast", data);
                _ThisPage.Page.Gift.RoomGiftGiveResult(data);
            },
            onGiftHeadlineBroadcast: function (data) {
                Log.Out('onGiftHeadlineBroadcast', data);
            },
            onHorn: function (data) {
                Log.Out("onHorn", data);
            },
            onHornBroadcast: function (data) {
                Log.Out("onHornBroadcast", data);
            },
            onPomeloGet: function (data) {
                Log.Out("onPomeloGet", data);
            },
            onPomeloPresent: function (data) {
                Log.Out("onPomeloPresent", data);
                _ThisPage.Page.PomeloUtil.ShowPomeloHistoryList(data);
            },
            onPomeloPresentBroadcast: function (data) {
                Log.Out("onPomeloPresentBroadcast", data);
                _ThisPage.Page.PomeloUtil.ShowPomeloHistoryList(data);
            },
            onMessage: function (data) {
                Log.Out("onMessage", data);
                _ThisPage.Page.Chat.Data.MsgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat(data.RoomUserInfo);//以服务器返回的用户数据为准。
                _ThisPage.Page.Chat.ChatShowMsg(_ThisPage.Page.Chat.Data.MsgObj);
            },
            onMessageBroadcast: function (data) {
                Log.Out("onMessageBroadcast", data);
                _ThisPage.Page.Chat.ChatServerMsgReceive(data);
            },
            onAdminSet: function (data) {
                Log.Out("onAdminSet", data);
            },
            onAdminSetBroadcast: function (data) {
                Log.Out("onAdminSetBroadcast", data);
            },
            onBlackSet: function (data) {
                Log.Out("onBlackSet", data);
            },
            onBlackSetBroadcast: function (data) {
                Log.Out("onBlackSetBroadcast", data);
            },
            onBlockSet: function (data) {
                Log.Out("onBlockSet", data);
            },
            onChangeCDN: function (data) {
            },

            onLottery: function (data) {
                Log.Out("onLottery", data);
                if (_ThisPage.Page.Game.RotateState) {
                    GameLottery.GameLotteryResult("onLottery", data);
                    GameLottery.GameLotteryResultShow("onRoomLottery", data);
                }
            },
            onRoomLottery: function (data) {
                Log.Out("onRoomLottery", data);
                if (_ThisPage.Page.Game.RotateState) {
                    GameLottery.GameLotteryResultShow("onRoomLottery", data);
                }
            },
            onServerLottery: function (data) {
                Log.Out("onServerLottery", data);
                if (_ThisPage.Page.Game.RotateState) {
                    if (data.RoomUserInfo.User_ID != $.CommonMainRoom.RoomUserInfo.User_ID) {
                        GameLottery.GameLotteryResultShow("onServerLottery", data);
                    }
                }
            },

            fnRoomInfo: function (data) {
                Log.Out("fnRoomInfo", data);
                _ThisPage.Page.Room.UpdateInfo(data);
            },
            fnRoomUserInfo: function (data) {
                Log.Out("fnRoomUserInfo", data);
            },
            fnRoomAnchorInfo: function (data) {
                Log.Out("fnRoomAnchorInfo", data);
                if (data.RoomID != _PageData.RoomID) return; //不是本房间的艺人信息，就拦截，不要更新。
                _ThisPage.Page.Anchor.UpdateInfo(data);
            },
            fnRoomGiftPond: function (data) {
                Log.Out("fnRoomGiftPond", data);
            },
            fnRoomGuardian: function (data) {
                Log.Out("fnRoomGuardian", data);
            },
            fnGiftHeadline: function (data) {
                Log.Out('fnGiftHeadline', data);
            },
            fnBlackJoin: function (data) {
                _ThisPage.Flash.EndLive();
                alert(data);
                window.document.location = _VirtualPath.Main;
            },
            fnErrorNotEnough: function (data) {
                Log.Out("fnErrorNotEnough", data);
            },
            fnErrorOther: function (data) {
                Log.Out("fnErrorOther", data);
                _ThisPage.Page.CommonUitls.Tip("Error " + data.message + "(" + data.flag + ")");
            },
            fnUserPackage: function (data) {
                Log.Out("fnUserPackage", data);
            }
        });
    });
</script>
</body>
</html>
